<HTML>
<HEAD>
<TITLE>JavaScript Source Code 3000:  Forms:  Form Target Formatting</TITLE>
<META HTTP-EQUIV="JavaScript Source Code 3000" CONTENT = "no-cache">
<META NAME="date" CONTENT="2000-09-09">
<META NAME="channel" CONTENT="Web Developer">
<META NAME="author" CONTENT="Cyanide_7 (leo7278@hotmail.com)">
<META NAME="section" CONTENT="Forms">
<META NAME="description" CONTENT="Allows you to format the target window of a form from the form's target property.  This allows for the use of window properties, variables, and other data manipulation to effect these options.  Great!">

<SCRIPT LANGUAGE="JavaScript">
<!-- Original:  Cyanide_7 (leo7278@hotmail.com) -->
<!-- Web Site:  http://www7.ewebcity.com/cyanide7 -->




<!-- Begin
// test variables
var myHeight = 200;
var isResizable = true;

function createTarget(form) {
_target = form.target;
_colon = _target.indexOf(":");
if(_colon != -1) {
form.target = _target.substring(0,_colon);
form.args = _target.substring(_colon+1);
} else if(typeof(form.args)=="undefined") {
form.args = "";
}
if(form.args.indexOf("{")!=-1) {
_args = form.args.split("{");
form.args = _args[0];
for(var i = 1; i < _args.length;i++) {
_args[i] = _args[i].split("}");
form.args += eval(_args[i][0]) + _args[i][1];
   }
}
form.args = form.args.replace(/ /g,"");
_win = window.open('',form.target,form.args);
if(typeof(focus)=="function")
_win.focus();
return true;
}
//  End -->
</script>
</HEAD>

<BODY BGCOLOR=#ffffff vlink=#0000ff>

<BR>
<center>
<table width=600 cellpadding=0 cellspacing=10>
<tr>
<td width=468 align=center>

    
    
</td>
<td width=120 align=center>
    
</td>
</tr>
</table>
<BR>
<BR>
<basefont size=3>
<FONT SIZE="+2" FACE="Helvetica,Arial">
<A HREF="../index.htm" /" TARGET="_top"><FONT COLOR="#0000FF"><b>Home</b></font></A>
<img src="../img/arrow.gif" /img/arrow.gif" height=13 width=7 border=0 alt="}">
<A HREF="index.htm" /forms/" ><font color="#FF0000"><b>Forms</b></font></A>
<img src="../img/arrow.gif" /img/arrow.gif" height=13 width=7 border=0 alt="}">
<FONT COLOR="#006666"><b>Form Target Formatting</b></font></font>
<BR>
<BR>
<table BORDER=0 WIDTH=486 CELLPADDING=3 CELLSPACING=0>
<tr><td><font FACE="helvetica,arial,geneva">
<br>
<br>
<!-- Description --><!--content_start-->
Allows you to format the target window of a form from the form's target property.  This allows for the use of window properties, variables, and other data manipulation to effect these options.  Great!
<hr>
</td></tr>
</table>
<!-- Demonstration -->
<center>
Form Target Formatting
<p>

<!-- Special Notes:  -->
<!-- Simply begin the target attribute with a name of your -->
<!-- choice, _blank, _top, etc... followed by a colon and -->
<!-- the window options string used in the window.open -->
<!-- command. Anything in this string enclosed in { and } -->
<!-- will be interpreted as JavaScript. -->

<form action="process-form.html-name=&email=&fav_color=.htm" /forms/process-form.html?name=&email=&fav_color=" method=get
target="foobar:width={window.screen.width/2},
         height={myHeight},
         scrollbars,
         {(isResizable)?'resizable':''},
         status"
onSubmit="return createTarget(this);">
<table align=center>
<tr><td align=right>Name:</td>
<td><input name=name></td></tr>
<tr><td align=right>Email:</td>
<td><input name=email></td></tr>
<tr><td align=right>Favorite Color:</td>
<td><input name=fav_color></td></tr>
<tr><td align=center colspan=2><input type="Submit"></td></tr>
</table>
</form>
<br>We set up our demo to open the form target window with a height of 200, and a width of 50%.<p>
</center>
<P>
<P>
<a name="source">
<table BORDER=0 WIDTH=486 CELLPADDING=3 CELLSPACING=0>
<tr><td BGCOLOR=yellow><font FACE="helvetica,arial,geneva"><b>JavaScript Source Code 3000:  Forms:  Form Target Formatting</b>
<p>Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as Note Pad or Simple Text) and save (Control-s or Apple-s).  The script is yours!!!
<br><br></font></td></tr>
<tr><td BGCOLOR=yellow ALIGN=CENTER>
<form NAME="copy">

<DIV align="center">
<input type=button value="Highlight All" onClick="javascript:this.form.txt.focus();this.form.txt.select();">&nbsp;&nbsp;&nbsp;&nbsp;
<INPUT TYPE="text" NAME="total" VALUE="Script Size:  2.27 KB" size=24>
</DIV>

<textarea NAME="txt" ROWS=20 COLS=75 WRAP=VIRTUAL>

&lt;!-- TWO STEPS TO INSTALL FORM TARGET FORMATTING:

  1.  Copy the coding into the HEAD of your HTML document
  2.  Add the last code into the BODY of your HTML document  --&gt;

&lt;!-- STEP ONE: Paste this code into the HEAD of your HTML document  --&gt;

&lt;HEAD&gt;

&lt;SCRIPT LANGUAGE="JavaScript"&gt;
&lt;!-- Original:  Cyanide_7 (leo7278@hotmail.com) --&gt;
&lt;!-- Web Site:  http://www7.ewebcity.com/cyanide7 --&gt;

&lt;! &gt;
&lt;! &gt;

&lt;!-- Begin
// test variables
var myHeight = 200;
var isResizable = true;

function createTarget(form) {
_target = form.target;
_colon = _target.indexOf(":");
if(_colon != -1) {
form.target = _target.substring(0,_colon);
form.args = _target.substring(_colon+1);
} else if(typeof(form.args)=="undefined") {
form.args = "";
}
if(form.args.indexOf("{")!=-1) {
_args = form.args.split("{");
form.args = _args[0];
for(var i = 1; i &lt; _args.length;i++) {
_args[i] = _args[i].split("}");
form.args += eval(_args[i][0]) + _args[i][1];
   }
}
form.args = form.args.replace(/ /g,"");
_win = window.open('',form.target,form.args);
if(typeof(focus)=="function")
_win.focus();
return true;
}
//  End --&gt;
&lt;/script&gt;
&lt;/HEAD&gt;

&lt;!-- STEP TWO: Copy this code into the BODY of your HTML document  --&gt;

&lt;BODY&gt;

&lt;center&gt;
Form Target Formatting
&lt;p&gt;

&lt;!-- Special Notes:  --&gt;
&lt;!-- Simply begin the target attribute with a name of your --&gt;
&lt;!-- choice, _blank, _top, etc... followed by a colon and --&gt;
&lt;!-- the window options string used in the window.open --&gt;
&lt;!-- command. Anything in this string enclosed in { and } --&gt;
&lt;!-- will be interpreted as JavaScript. --&gt;

&lt;form action="YOUR-CGI-SCRIPT.CGI" method=get
target="foobar:width={window.screen.width/2},
         height={myHeight},
         scrollbars,
         {(isResizable)?'resizable':''},
         status"
onSubmit="return createTarget(this);"&gt;
&lt;table align=center&gt;
&lt;tr&gt;&lt;td align=right&gt;Name:&lt;/td&gt;
&lt;td&gt;&lt;input name=name&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=right&gt;Email:&lt;/td&gt;
&lt;td&gt;&lt;input name=email&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=right&gt;Favorite Color:&lt;/td&gt;
&lt;td&gt;&lt;input name=fav_color&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=center colspan=2&gt;&lt;input type="Submit"&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;
&lt;/center&gt;

 

&lt;!-- Script Size:  2.27 KB --&gt;</textarea><br><font FACE="helvetica,arial,geneva"></font></td></tr>

</table>
</form>
</FONT>
</CENTER>


</center>
</body></html>